﻿using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio.CommandBars;
using System.Diagnostics.Contracts;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;

namespace MoXAML.Infrastructure
{
    /// <summary>
    /// All MoXAML Power Toys must implement this interface.
    /// </summary>
    [ContractClass(typeof(CommandBaseContract))]
    [InheritedExport] // By default, all elements that implement this interface can now be discovered via MEF.
    public interface ICommandBase : IDisposable
    {
        /// <summary>
        /// Initialize the instance of the command.
        /// </summary>
        /// <param name="application">The VS application.</param>
        /// <param name="addInInstance">The add in instance.</param>
        void Initialize(DTE2 application, AddIn addInInstance);

        /// <summary>
        /// Gets or sets the command name.
        /// </summary>
        string CommandName { get; set; }

        /// <summary>
        /// Gets or sets the caption to be displayed for the command.
        /// </summary>
        string Caption { get; set;  }

        /// <summary>
        /// Register the command with the parent.
        /// </summary>
        /// <param name="parentControl">The menu that is the parent of this command.</param>
        void Register(CommandBarPopup parentControl);

        /// <summary>
        /// Disconnect the command.
        /// </summary>
        void Close();

        bool CanExecute(vsCommandExecOption executeOption);

        void Execute();

        /// <summary>
        /// Gets the command bar that this should belong to.
        /// </summary>
        List<CommandBarType> ParentCommandBar { get; }

        /// <summary>
        /// Get the status that the command is at.
        /// </summary>
        /// <returns>The command status.</returns>
        /// <remarks>By default, the command status we are going with is vsCommandStatus.vsCommandStatusEnabled | vsCommandStatus.vsCommandStatusSupported.</remarks>
        vsCommandStatus GetStatus();
    }
}
